<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"   %>
<head>
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta http-equiv="Pragma" content="no-cache">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="format-detection" content="telephone=no" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<link href="${pageContext.request.contextPath}/css/bksystem.css" rel="stylesheet" type="text/css" />
	<link href="${pageContext.request.contextPath}/font/iconfont.css" rel="stylesheet" type="text/css" />
	<link href="${pageContext.request.contextPath}/css/module.css" rel="stylesheet" type="text/css" />
	<link href="${pageContext.request.contextPath}/css/pages.css" rel="stylesheet" type="text/css" />
	<title>品牌管理</title>
	<script src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/jquery.nicescroll.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/HUpages.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/template.js" type="text/javascript"></script>
	<!--[if lt IE 9]>
	<script src="${pageContext.request.contextPath}/js/html5shiv.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/css3-mediaqueries.js"  type="text/javascript"></script>
	<![endif]-->


	<style>
		.divs{

			width: 100%;
			height: 30px;
			border: 1px solid bisque;
			text-align: center;
			color: red;
			background-color: wheat;
			text-align: center;
			line-height:2;

		}
	</style>
</head>

<body id="pagestyle">

<c:if test="${! empty fla}">
	<script>
		alert("${fla}");
	</script>
	<c:remove var="fla"></c:remove>
</c:if>



<div class="pages-style">
	<!--左侧菜单栏-->
	<div class="bk-con-menu " id="bk-con-menu">
		<div class="menubtn">
			<span class="close_btn samebtn"><i>隐藏</i></span>
			<span class="show_btn samebtn"><i>显示</i></span>
		</div>
		<div class="title-menu">栏目分类</div>
		<div class="breadcrumb" id="breadcrumb">
			<ul class="clearfix menu-section menulist" id="brandsort">
				<li>
					<div class="divs">
						<a href="order/quer.html?id=${Bus.id}&osid=5" >订单管理</a>
					</div>
				</li>
			</ul>
		</div>
	</div>
	<!---->

	<div class="bk-con-message message-section" id="iframe_box">
		<!--编辑内容-->
		<div class="operation  mb15">
			<button class="btn button_btn btn-danger" type="button" onclick=""><i class="iconfont">&#xe601</i>&nbsp;批量删除</button>
			<a href="${pageContext.request.contextPath}/business/listing.do"><button class="btn button_btn btn-blue" type="button"><i class="iconfont icon-yonghuguanli"></i>上架商品</button></a>
		</div>
		<div class="page_content clearfix mb15 table-module ">
			<div class="brandlist" id="brandlist">
			</div>
		</div>
	</div>
</div>
</body>

</html>
<script id="brandsorthtml" type="text/html">
<%--	<% for(int i = 0; i < sort.length; i++) { %>--%>
<%--	<li onclick="sortname()" class="sortname " data-id="<%=sort[i].id%>">--%>
<%--		<%=sort[i].name%> ( <%=sort[i].quantity %> )--%>
<%--	</li>--%>
<%--	<% } %>--%>
</script>

<script id="brandhtml" type="text/html">
	<c:forEach items="${countsStocks}" var="list">
	<div class="brand-info">
		<div class="brand_operating">
			<c:if test="${ list.grounding_id==1}">
				<span class="name_status  plf10" data-id="1" grounding_id="${ list.grounding_id}"  goodid="${list.goods_id}" business="${list.business_id}"    onclick="clickstatus(this)">启用</span>
			</c:if>
			<c:if test="${ list.grounding_id==0}">
				<span class="name_status  plf10"  data-id="${ list.grounding_id}" grounding_id="${ list.grounding_id}"  business="${list.business_id}"  goodid="${list.goods_id}"  onclick="clickstatus(this)">不启用</span>
			</c:if>
			<i class="iconfont deletebtn brand_operat"   goods="${list.goods_id}"  businessid="${list.business_id}"    onclick="deleteBrand(this)">&#xe601</i>
			<a href="${pageContext.request.contextPath}/business/reviseGoods.do?goodsid=${ list.goods_id}"><i class='iconfont brand_operat modifybtn' id='modifyN' onclick="modifyBrand(this)">&#xe61a</i></a>
		</div>
		<a href="#" class="clearfix brand_border padding0">
			<div class="brand_img">
				<img data-gid="${list.goods_id}"  src="${list.thumb_img}" alt="" onerror="imgGet(this),this.onerror=null" width="100%">
			</div>
			<div class="brand_content">
				<h5 class="brand_title">${list.goods_name}</h5>
				<div class="clearfix padding10 color9 backgroundf2"><span class="l_f">
<%--            	<% for(var s = 0; s < sort.length; s++) { %>--%>
<%--            		<% if(sort[s].id==list[i].sort) {%>--%>
<%--            			    <%=sort[s].name%>--%>
<%--            			<%}%>--%>
<%--                <% } %>--%>
            </span><span class="r_f">数量：${list.sum}</span></div>


			</div>
		</a>
	</div>
	</c:forEach>







<%--	<% for(var i = 0; i < list.length; i++) { %>--%>
<%--	<div class="brand-info">--%>
<%--		<div class="brand_operating">--%>
<%--			<% if(list[i].status==0) {%>--%>
<%--			<span class="name_status  plf10" data-id="0" onclick="clickstatus(this)">不启用</span>--%>
<%--			<%} if(list[i].status==1) {%>--%>
<%--			<span class="name_status  plf10" data-id="1" onclick="clickstatus(this)">启用</span>--%>
<%--			<%}%>--%>
<%--			<i class="iconfont deletebtn brand_operat" onclick="deleteBrand(this)">&#xe601</i>--%>
<%--			<i class='iconfont brand_operat modifybtn' id='modifyN' onclick="modifyBrand(this)">&#xe61a</i>--%>
<%--		</div>--%>

<%--		<a href="#" class="clearfix brand_border padding0">--%>
<%--			<div class="brand_img">--%>
<%--				<img src="images/logo/<%=list[i].logoImg %>" alt="" onerror="this.src='images/noimage.gif',this.onerror=null" width="100%">--%>
<%--			</div>--%>
<%--			<div class="brand_content">--%>
<%--				<h5 class="brand_title"><%=list[i].name%></h5>--%>
<%--				<div class="clearfix padding10 color9 backgroundf2"><span class="l_f">--%>
<%--            	<% for(var s = 0; s < sort.length; s++) { %>--%>
<%--            		<% if(sort[s].id==list[i].sort) {%>--%>
<%--            			    <%=sort[s].name%>--%>
<%--            			<%}%>--%>
<%--                <% } %>--%>
<%--            </span><span class="r_f">数量：<%=list[i].quantity%></span></div>--%>
<%--			</div>--%>
<%--		</a>--%>
<%--	</div>--%>
<%--	<% } %>--%>
</script>
<script>
	$(function() {
		//内页框架结构编辑
		$("#pagestyle").Hupage({
			slide: '#breadcrumb',
			padding: 15,
			menuModule: '#bk-con-menu', //菜单模块
			pagecontent: '.page_content', //自定义属性
			operation: '.operation', //自定义属性
			scrollbar: function(e) {
				e.niceScroll({
					cursorcolor: "#dddddd",
					cursoropacitymax: 1,
					touchbehavior: false,
					cursorwidth: "3px",
					cursorborder: "0",
					cursorborderradius: "3px",
				});
			},
			expand: function(thisBox, settings) {
				var pc = "";
				$(settings.pagecontent).css("margin-bottom") != null ? pc = parseInt($(settings.pagecontent).css("margin-bottom").replace("px", "")) : '';
				$(settings.pagecontent).css({
					height: $(window).height() - $(settings.operation).outerHeight() - pc - (settings.padding * 2)
				})
				settings.scrollbar($(settings.slide) && $(settings.pagecontent));
			} //自定义方法
		});
		//获取数据
		function Brandlist() {
			var loadMore = function(callback) {
				$.ajax({
					url: "json/brand.json",
					type: "GET",
					dataType: 'json',
					success: function(ret) {
						typeof callback == 'function' && callback(ret);
					},
				});
			};
			loadMore(function(listArr) {
				var listhtml = $('#brandlist');
				var sorthtml=$("#brandsort");
				var html = template('brandhtml', {
					list: listArr.brandlist,
					sort: listArr.brandSort
				});
				var shtml = template('brandsorthtml', {
					sort: listArr.brandSort
				});
				listhtml.append(html);
				sorthtml.append(shtml);
				var status = listhtml.find('.brand-info');
				for(var i = 0; i < status.length; i++) {
					var statusid = listhtml.find('.name_status').eq(i).attr('data-id');
					if(statusid != 1) {
						listhtml.find('.name_status').eq(i).addClass('statusNO');
					}
				}
			});
		}
		Brandlist();
		//启用状态

		//删除

        //修改
        function modifyBrand(e){

        }
	});

	function clickstatus(e) {


		 location.href="con/xiugai.html?goodid="+$(e).attr("goodid")+"&groundingid="+$(e).attr("grounding_id")+"&business_id="+$(e).attr("business")


	};
    function deleteBrand(e){
     var flag=confirm("确定删除")
        if (flag){
            alert("真")

			alert($(e).attr("goods"))
			alert($(e).attr("businessid"))


         location.href="con/delete.html?goodsid="+$(e).attr("goods")+"&businessid="+$(e).attr("businessid")


        }else {
            alert("假")
        }


    };


</script>

<script>
	function imgGet(img){
		let goodsid=$(img).data("gid");
		$.ajax({
			url:"${pageContext.request.contextPath}/business/queryImgByGoodsId.do",
			async:false,
			data: {goodsId:goodsid},
			dataType:"json",
			success:function (data) {
				let url="images/noimage.gif";
				for (let i = 0; i < data.length; i++) {
					if(data[i].img_classify==0){
						url="img/"+data[i].img_url;
						break;
					}
				}
				img.src="${pageContext.request.contextPath}/"+url;

			}
		})
	}
</script>